package com.kfm.am;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Objects;

public class Test {

    public static void main(String[] args) {
        // 最终存储的数据是 Object
        ArrayList arrayList = new ArrayList();
        arrayList.add(1);
        arrayList.add("1");
//        Object obj = arrayList.get(0);
//        String s1 = (String)obj;
        // 最终存储的数据变成String
        // ArrayList<Integer> E --> String
        // ArrayList<Student> E --> Student get(1)  Student
        ArrayList<String> arrayList1 = new ArrayList<>();
        arrayList1.add("1");
        String str = arrayList1.get(0);
        System.out.println(str.length());
        // 会进行类型检查
        // arrayList1.add(1);
        ArrayList<Movie> movieList = new ArrayList<Movie>();
        movieList.add(new Movie("爱乐之城", new Date(2016 - 1900, 1, 1)));
        movieList.add(new Movie("孤注一掷", new Date(2023 - 1900, 7, 10)));
        movieList.add(new Movie("封神", new Date(2023 - 1900, 7, 20)));
//        movieList.add(1);
        Movie movie = movieList.get(0);
        System.out.println(movie.getName());

        Comparator c = new Comparator() {
            @Override
            public int compare(Object o1, Object o2) {
                Movie movie1 = (Movie) o1;
                Movie movie2 = (Movie) o2;
                return movie1.getDate().compareTo(movie2.getDate());
            }
        };

        Comparator<String> c1 = new Comparator<>() {
            @Override
            public int compare(String o1, String o2) {
//                Movie movie1 = (Movie) o1;
//                Movie movie2 = (Movie) o2;
                return o1.compareTo(o2);
            }
        };

        Comparator<Movie> comparator = new Comparator<Movie>() {
            @Override
            public int compare(Movie o1, Movie o2) {
                return o1.getDate().compareTo(o2.getDate());
            }
        };
        // E --> Movie  Comparator<? super Movie>
        movieList.sort(comparator);

//        movieList.sort(c1);

    }
}
